package cc.realxyq.demo.config;

import cc.realxyq.demo.bean.Person;
import cc.realxyq.demo.controller.BookController;
import cc.realxyq.demo.filter.CustomTypeFilter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.FilterType;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Service;

/**
 * bean的注入 @bean方式
 * @author kwhan
 * @date 2022年01月07日 4:47
 */
@ComponentScan(value = "cc.realxyq.demo", includeFilters = {
        @ComponentScan.Filter(type = FilterType.ANNOTATION, classes = {Controller.class,Service.class}),
        @ComponentScan.Filter(type = FilterType.CUSTOM,value = CustomTypeFilter.class)},
        excludeFilters = {
        @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = BookController.class)
        },
        useDefaultFilters = false)
@Configuration
public class ComponentScanConfig {
    @Bean
    public Person person() {
        return new Person("lisi", 18);
    }
}
